package com.leetcode.algorithm.y22.m06;

/**
 * 1281. 整数的各位积和之差
 * 
 * https://leetcode.cn/problems/subtract-the-product-and-sum-of-digits-of-an-integer/
 * 
 * @author jie.deng
 *
 */
class Question1281Solution01 {

	public int subtractProductAndSum(int n) {
		int sum = 0;
		int mul = 1;
		while (n > 0) {
			int i = n % 10;
			sum += i;
			mul *= i;
			n /= 10;
		}
		return mul - sum;
	}

}